function Get-NewAzureDatabaseName {
    Param (
        [Parameter(Mandatory = $false)][String[]]$Blocklist,
        [Parameter(Mandatory = $false)][string]$DatabaseName,
        [Parameter(Mandatory = $false)][bool]$ConfirmAll = $false
    )

    # Allow user to use existing value or to update it.
    if ((Confirm-SingleValue -Description 'New Azure SQL database name' -Value $DatabaseName -ConfirmAll $ConfirmAll) -eq $true) { return $DatabaseName }

    # Get regex from config file.
    $regex = (Read-Config).Regex.AzureSQLDatabase # Length 1-128 (Probably with server name and '/' prepended, so we restrict the max length to 63). Can't use <>*%&:\/?. Can't end with period or space.
    
    # Ask user for a new name.
    Write-Host # Newline.
    Write-Host 'Please provide a name for the new Azure SQL database resource. Cannot use <>*%&:\/? and cannot end with a period. Is 1-63 characters in length.'
    do {
        $newName = Read-Host -Prompt "Database name"
        if ($newName -iin $Blocklist) {
            $newName = $null
            Write-Warning 'Invalid name! The name you gave is already in use.'
        } elseif ($newName -cnotmatch $regex) {
            # Reset name if it doesn't match the regex.
            $newName = $null
            Write-Warning 'Invalid name! The name you gave had incorrect syntax.'
        }
    } while (!$newName)
    return $newName
}